import OrdersLoginService from "@/api/order/OrdersLoginService";
const user = {
	namespaced: true,
	state: {
		user: null,
		busiManagerId: "", //新建订单页面业务经理
		custManagerId: "", //新建订单页面客户经理
	},

	mutations: {
		SET_USER: (state, myval) => {
			state.user = myval;
		},
		SET_BUSIMANAGERID: (state, value) => {
			state.busiManagerId = value;
		},
		SET_CUSTMANAGERID: (state, value) => {
			state.custManagerId = value;
		},
	},

	actions: {
		/**
		 * 查询用户信息
		 */
		async queryLoginUserInfo({ commit }) {
			const res = await OrdersLoginService.queryLoginUserInfo();
			if (res.code == '200') {
				res.meta.sysUserId = res.meta.acctId;
				res.meta.commonRegionId = res.meta.regionId;
				commit("SET_USER", res.meta);
				
				sessionStorage.setItem("crm3-userinfo", JSON.stringify(res.meta));
			}else{
				
			}
			
		}
	},
};

export default user;
